var mysql = require('mysql');

var pool = null;

exports.init = function(callback) {
    var options = {
        host : config.mysql.gm.ip,
        port : config.mysql.gm.port,
        user : config.mysql.user,
        password : config.mysql.password,
        database : 'stat',
        insecureAuth: true,
    };
    
    pool = mysql.createPool(options);

    pool.getConnection(function(err, connection) {
        if (connection) {
            connection.release();
        }
        callback(err);
    });
};

exports.query = function(sql, callback) {
    pool.query(sql, callback);
};

exports.format = mysql.format;

exports.pool = pool;
